package com.ruima.study.jdk21.jdk21.demo2;

/**
 * <p>
 * <p></p>
 * <p>
 * <p>Copyright (c) 2024/11/14 15:40, 科大讯飞 All Rights Reserve</p>
 *
 * @author ruima6
 * @version [V1.0]
 */
public class RecordDemo {
    public static void main(String[] args) {
    Student s = new Student(10, "jordan");
    printSum(s);
}

    static void printSum(Object obj) {
        //这里的Student(int a, String b)就是 record pattern
        if (obj instanceof Student(int a, String b)) {
            System.out.println("id:" + a);
            System.out.println("name:" + b);
        }
    }

}
record Student(int id, String name) {}
